const path = require("path");
const htmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require('webpack')

module.exports = {
    mode: "development",
    devtool: "eval-source-map",
    entry: path.join(__dirname, "src/index.js"),
    devServer: {
        static: {
            directory: path.join(__dirname, './dist')
        },
        open: true,
        hot: "only"
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: ["style-loader", "css-loader"]
            },
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel-loader",
            }
        ]
    },
    output: {
        publicPath: '/',
        filename: "[name]-[hash:8].js",
        path: path.join(__dirname, "dist")
    },
    plugins: [
        new htmlWebpackPlugin({template: "./src/index.html"}),
        new webpack.HotModuleReplacementPlugin({})
    ]
};
